home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / util / setcpu16 / part01 next >
Encoding:
Text File  |  1990-08-14  |  55.9 KB  |  2,016 lines

  1. Newsgroups: comp.sources.amiga
  2. Path: abcfd20.larc.nasa.gov!amiga-request
  3. From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  4. Subject: v90i221: SetCPU 1.60 - identify and adjust parameters based on cpu type, Part01/04
  5. Message-ID: <comp.sources.amiga:v90i221@abcfd20.larc.nasa.gov>
  6. Sender: tadguy@abcfd20.larc.nasa.gov (Tad Guy)
  7. Reply-To: daveh@cbmvax.commodore.com (Dave Haynie)
  8. X-Post-Discussions-To: comp.sys.amiga
  9. Organization: NASA Langley Research Center, Hampton, VA  USA
  10. Date: 14 Aug 90 21:35:39 GMT
  11. Approved: tadguy@abcfd01.larc.nasa.gov (Tad Guy)
  12. X-Mail-Submissions-To: amiga@uunet.uu.net
  13.  
  14. Submitted-by: daveh@cbmvax.commodore.com (Dave Haynie)
  15. Posting-number: Volume 90, Issue 221
  16. Archive-name: util/setcpu-1.60/part01
  17.  
  18. [ uuencoded executable enclosed  ...tad ]
  19.  
  20. Here's the latest SetCPU program.  This archive contains the executable,
  21. docs, and source files.  This program is used to identify the CPU/FPU/MMU
  22. combinations in an Amiga computer, make decisions based on this, modify
  23. cache parameters, and on MMU-Based machines, run ROM emulations.   The ROM
  24. emulation mechanism now supports 512K ROMs such as those used for AmigaOS 2.0.
  25. This program and the sources are public domain.  
  26.  
  27.                                         -Dave Haynie
  28.  
  29. #!/bin/sh
  30. # This is a shell archive.  Remove anything before this line, then unpack
  31. # it by saving it into a file and typing "sh file".  To overwrite existing
  32. # files, type "sh file -c".  You can also feed this as standard input via
  33. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  34. # will see the following message at the end:
  35. #        "End of archive 1 (of 4)."
  36. # Contents:  CardROMList control.a control.i diskio.c expdev.c idents.a
  37. #   makefile misc.c other.a reboot.a setcpu.i
  38. # Wrapped by tadguy@abcfd20 on Tue Aug 14 17:35:34 1990
  39. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  40. if test -f 'CardROMList' -a "${1}" != "-c" ; then 
  41.   echo shar: Will not clobber existing file \"'CardROMList'\"
  42. else
  43. echo shar: Extracting \"'CardROMList'\" \(59 characters\)
  44. sed "s/^X//" >'CardROMList' <<'END_OF_FILE'
  45. X0x202 0x01 0x10000 0x8000 0x4000 CBM_2090A_Disk_Controller
  46. END_OF_FILE
  47. if test 59 -ne `wc -c <'CardROMList'`; then
  48.     echo shar: \"'CardROMList'\" unpacked with wrong size!
  49. fi
  50. # end of 'CardROMList'
  51. fi
  52. if test -f 'control.a' -a "${1}" != "-c" ; then 
  53.   echo shar: Will not clobber existing file \"'control.a'\"
  54. else
  55. echo shar: Extracting \"'control.a'\" \(5731 characters\)
  56. sed "s/^X//" >'control.a' <<'END_OF_FILE'
  57. X;======================================================================
  58. X;
  59. X;    SetCPU V1.60
  60. X;    by Dave Haynie, April 13, 1990
  61. X;    Released to the Public Domain
  62. X;
  63. X;    CONTROL.A MODULE
  64. X;
  65. X;    This module contains functions that access various control
  66. X;    registers in the 32 bit CPUs and MMUs.
  67. X;
  68. X;======================================================================
  69. X
  70. X    include "setcpu.i"
  71. X
  72. X    cseg
  73. X
  74. X;**********************************************************************
  75. X;
  76. X;    These functions work with the CPU control registers.
  77. X;
  78. X**********************************************************************
  79. X
  80. X    xdef    _SetCACR    ; Set CACR register
  81. X    xdef    _GetCACR    ; Get CACR register
  82. X    xdef    _GetVBR        ; Get the Vector Base Register
  83. X
  84. X;======================================================================
  85. X;
  86. X;    This function sets the value of the 68020/68030 CACR register.  
  87. X;    It assumes a 68020 or 68030 based system.
  88. X;
  89. X;    void SetCACR(cacr)
  90. X;    ULONG cacr;
  91. X;
  92. X;======================================================================
  93. X
  94. X_SetCACR:
  95. X    move.l    4(sp),d0        ; New CACR is on stack
  96. X     move.l    4,a6            ; Get ExecBase
  97. X
  98. X    move.w    LIB_VERSION(a6),d1    ; Are we in 2.0?
  99. X    cmp.w    #36,d1            ; If so, use the 2.0 function
  100. X    blt    MySetCACR
  101. X
  102. X    move.l    #$ffffffff,d1
  103. X    CALLSYS    CacheControl
  104. X    rts    
  105. X
  106. XMySetCACR:
  107. X    move.l    a5,-(sp)        ; Save this register
  108. X    lea.l    1$,a5            ; Get the start of the supervisor code
  109. X    CALLSYS    Supervisor
  110. X    move.l    (sp)+,a5        ; Give it back
  111. X    rts
  112. X1$
  113. X    MOVEC_    d0,cacr            ; Set the CACR
  114. X    rte
  115. X
  116. X;======================================================================
  117. X;
  118. X;    This function returns the 68020/68030 CACR register.  It assumes
  119. X;    a 68020 or better system.
  120. X;
  121. X;    ULONG GetCACR()
  122. X;
  123. X;======================================================================
  124. X
  125. X_GetCACR:
  126. X    move.l    4,a6            ; Get ExecBase
  127. X
  128. X    move.w    LIB_VERSION(a6),d1    ; Are we in 2.0?
  129. X    cmp.w    #36,d1            ; If so, use the 2.0 function
  130. X    blt    MyGetCACR
  131. X
  132. X    moveq.l    #0,d0
  133. X    move.l    d0,d1
  134. X    CALLSYS    CacheControl
  135. X    rts
  136. X
  137. XMyGetCACR:
  138. X    move.l    a5,-(sp)        ; Save this register
  139. X    lea.l    1$,a5            ; Get the start of the supervisor code
  140. X    CALLSYS    Supervisor
  141. X    move.l    (sp)+,a5        ; Give back register
  142. X    rts
  143. X1$
  144. X    MOVEC_    cacr,d0            ; Make CACR the return value
  145. X    rte
  146. X
  147. X;======================================================================
  148. X;
  149. X;    This function returns the value of the Vector Base Register;
  150. X;    all exceptions are referenced from this.  This function assumes
  151. X;    we're on a CPU with a VBR (eg, no 68000's need apply).
  152. X;
  153. X;    ULONG *GetVBR()
  154. X;
  155. X;======================================================================
  156. X
  157. X_GetVBR:
  158. X    move.l    4,a6            ; Get ExecBase
  159. X    move.l    a5,-(sp)        ; Save this register
  160. X    lea.l    1$,a5            ; Get the start of the supervisor code
  161. X    CALLSYS    Supervisor
  162. X    move.l    (sp)+,a5        ; Give back register
  163. X    rts
  164. X1$
  165. X    MOVEC_    vbr,d0            ; Make CACR the return value
  166. X    rte
  167. X
  168. X;**********************************************************************
  169. X;
  170. X;    These functions access MMU registers
  171. X;
  172. X;**********************************************************************
  173. X
  174. X    xdef    _GetCRP        ; Gets MMU CRP register
  175. X    xdef    _SetCRP        ; Sets MMU CRP register
  176. X    xdef    _GetTC        ; Gets MMU TC register
  177. X    xdef    _SetTC        ; Gets MMU TC register
  178. X
  179. X;======================================================================
  180. X;
  181. X;    This function returns the MMU CRP register.  It assumes a 68020 
  182. X;    system with MMU, or a 68030 based system (eg, test for MMU before
  183. X;    you call this, or you wind up in The Guru Zone).  Note that the
  184. X;    CRP register is two longwords long.
  185. X;
  186. X;    void GetCRP(ULONG *)
  187. X;
  188. X;======================================================================
  189. X
  190. X_GetCRP:
  191. X    move.l    4(sp),a0        ; Pointer to the CRP storage area
  192. X    move.l    4,a6            ; Get ExecBase
  193. X    move.l    a5,-(sp)
  194. X    lea.l    2$,a5            ; Get the start of the supervisor code
  195. X    CALLSYS    Supervisor
  196. X    move.l    (sp)+,a5
  197. X    rts
  198. X2$
  199. X    PMOVE_    crp,(a0)        ; Just get the CRP register
  200. X    rte
  201. X
  202. X;======================================================================
  203. X;
  204. X;    This function sets the MMU CRP register.  It assumes a 68020 
  205. X;    system with MMU, or a 68030 based system (eg, test for MMU before
  206. X;    you call this, or you wind up in The Guru Zone).  Note that the
  207. X;    CRP register is two longwords long.
  208. X;
  209. X;    void SetCRP(ULONG *)
  210. X;
  211. X;======================================================================
  212. X
  213. X_SetCRP:
  214. X    move.l    4(sp),a0        ; Pointer to the CRP storage area
  215. X    move.l    4,a6            ; Get ExecBase
  216. X    move.l    a5,-(sp)
  217. X    lea.l    1$,a5            ; Get the start of the supervisor code
  218. X    CALLSYS    Supervisor
  219. X    movem.l    (sp)+,a5        ; Give back registers
  220. X    rts
  221. X1$
  222. X    PMOVE_    (a0),crp        ; Just load the CRP register
  223. X    rte
  224. X
  225. X;======================================================================
  226. X;
  227. X;    This function returns the MMU TC register.  It assumes a 68020 
  228. X;    system with MMU, or a 68030 based system (eg, test for MMU before
  229. X;    you call this, or you wind up in The Guru Zone).  
  230. X;
  231. X;    ULONG GetTC()
  232. X;
  233. X;======================================================================
  234. X
  235. X_GetTC:
  236. X    move.l    4,a6            ; Get ExecBase
  237. X    move.l    a5,-(sp)
  238. X    subq.l    #4,sp            ; Make a place to dump TC
  239. X    move.l    sp,a0
  240. X    lea.l    1$,a5            ; Get the start of the supervisor code
  241. X    CALLSYS    Supervisor
  242. X    move.l    (sp),d0            ; Here's the result
  243. X    addq.l    #4,sp
  244. X    move.l    (sp)+,a5
  245. X    rts
  246. X1$
  247. X    PMOVE_    tc,(a0)            ; Just get the TC register
  248. X    rte
  249. X
  250. X;======================================================================
  251. X;
  252. X;    This function sets the MMU TC register.  It assumes a 68020 
  253. X;    system with MMU, or a 68030 based system (eg, test for MMU before
  254. X;    you call this, or you wind up in The Guru Zone).  
  255. X;
  256. X;    void SetTC(ULONG)
  257. X;
  258. X;======================================================================
  259. X
  260. X_SetTC:
  261. X    lea.l    4(sp),a0        ; Get address of our new TC value
  262. X    move.l    4,a6            ; Get ExecBase
  263. X    move.l    a5,-(sp)
  264. X    lea.l    1$,a5            ; Get the start of the supervisor code
  265. X     CALLSYS    Supervisor
  266. X    move.l    (sp)+,a5
  267. X    rts
  268. X1$
  269. X    PMOVE_    (a0),tc            ; Just set the TC register
  270. X    rte
  271. X
  272. X    end
  273. END_OF_FILE
  274. if test 5731 -ne `wc -c <'control.a'`; then
  275.     echo shar: \"'control.a'\" unpacked with wrong size!
  276. fi
  277. # end of 'control.a'
  278. fi
  279. if test -f 'control.i' -a "${1}" != "-c" ; then 
  280.   echo shar: Will not clobber existing file \"'control.i'\"
  281. else
  282. echo shar: Extracting \"'control.i'\" \(5383 characters\)
  283. sed "s/^X//" >'control.i' <<'END_OF_FILE'
  284. X;======================================================================
  285. X;
  286. X;    SetCPU V1.60
  287. X;    by Dave Haynie, April 13, 1990
  288. X;    Released to the Public Domain
  289. X;
  290. X;    CONTROL.A MODULE
  291. X;
  292. X;    This module contains functions that access various control
  293. X;    registers in the 32 bit CPUs and MMUs.
  294. X;
  295. X;======================================================================
  296. X
  297. X    include "setcpu.i"
  298. X
  299. X    cseg
  300. X
  301. X;**********************************************************************
  302. X;
  303. X;    These functions work with the CPU control registers.
  304. X;
  305. X**********************************************************************
  306. X
  307. X    xdef    _SetCACR    ; Set CACR register
  308. X    xdef    _GetCACR    ; Get CACR register
  309. X    xdef    _GetVBR        ; Get the Vector Base Register
  310. X
  311. X;======================================================================
  312. X;
  313. X;    This function sets the value of the 68020/68030 CACR register.  
  314. X;    It assumes a 68020 or 68030 based system.
  315. X;
  316. X;    void SetCACR(cacr)
  317. X;    ULONG cacr;
  318. X;
  319. X;======================================================================
  320. X
  321. X_SetCACR:
  322. X    move.l    4(sp),d0        ; New CACR is on stack
  323. X     move.l    4,a6            ; Get ExecBase
  324. X    move.l    a5,-(sp)        ; Save this register
  325. X    lea.l    1$,a5            ; Get the start of the supervisor code
  326. X    CALLSYS    Supervisor
  327. X    move.l    (sp)+,a5        ; Give it back
  328. X    rts
  329. X1$
  330. X    MOVEC_    d0,cacr            ; Set the CACR
  331. X    rte
  332. X
  333. X;======================================================================
  334. X;
  335. X;    This function returns the 68020/68030 CACR register.  It assumes
  336. X;    a 68020 or better system.
  337. X;
  338. X;    ULONG GetCACR()
  339. X;
  340. X;======================================================================
  341. X
  342. X_GetCACR:
  343. X    move.l    4,a6            ; Get ExecBase
  344. X    move.l    a5,-(sp)        ; Save this register
  345. X    lea.l    1$,a5            ; Get the start of the supervisor code
  346. X    CALLSYS    Supervisor
  347. X    move.l    (sp)+,a5        ; Give back register
  348. X    rts
  349. X1$
  350. X    MOVEC_    cacr,d0            ; Make CACR the return value
  351. X    rte
  352. X
  353. X;======================================================================
  354. X;
  355. X;    This function returns the value of the Vector Base Register;
  356. X;    all exceptions are referenced from this.  This function assumes
  357. X;    we're on a CPU with a VBR (eg, no 68000's need apply).
  358. X;
  359. X;    ULONG *GetVBR()
  360. X;
  361. X;======================================================================
  362. X
  363. X_GetVBR:
  364. X    move.l    4,a6            ; Get ExecBase
  365. X    move.l    a5,-(sp)        ; Save this register
  366. X    lea.l    1$,a5            ; Get the start of the supervisor code
  367. X    CALLSYS    Supervisor
  368. X    move.l    (sp)+,a5        ; Give back register
  369. X    rts
  370. X1$
  371. X    MOVEC_    vbr,d0            ; Make CACR the return value
  372. X    rte
  373. X
  374. X;**********************************************************************
  375. X;
  376. X;    These functions access MMU registers
  377. X;
  378. X;**********************************************************************
  379. X
  380. X    xdef    _GetCRP        ; Gets MMU CRP register
  381. X    xdef    _SetCRP        ; Sets MMU CRP register
  382. X    xdef    _GetTC        ; Gets MMU TC register
  383. X    xdef    _SetTC        ; Gets MMU TC register
  384. X
  385. X;======================================================================
  386. X;
  387. X;    This function returns the MMU CRP register.  It assumes a 68020 
  388. X;    system with MMU, or a 68030 based system (eg, test for MMU before
  389. X;    you call this, or you wind up in The Guru Zone).  Note that the
  390. X;    CRP register is two longwords long.
  391. X;
  392. X;    void GetCRP(ULONG *)
  393. X;
  394. X;======================================================================
  395. X
  396. X_GetCRP:
  397. X    move.l    4(sp),a0        ; Pointer to the CRP storage area
  398. X    move.l    4,a6            ; Get ExecBase
  399. X    move.l    a5,-(sp)
  400. X    lea.l    2$,a5            ; Get the start of the supervisor code
  401. X    CALLSYS    Supervisor
  402. X    move.l    (sp)+,a5
  403. X    rts
  404. X2$
  405. X    PMOVE_    crp,(a0)        ; Just get the CRP register
  406. X    rte
  407. X
  408. X;======================================================================
  409. X;
  410. X;    This function sets the MMU CRP register.  It assumes a 68020 
  411. X;    system with MMU, or a 68030 based system (eg, test for MMU before
  412. X;    you call this, or you wind up in The Guru Zone).  Note that the
  413. X;    CRP register is two longwords long.
  414. X;
  415. X;    void SetCRP(ULONG *)
  416. X;
  417. X;======================================================================
  418. X
  419. X_SetCRP:
  420. X    move.l    4(sp),a0        ; Pointer to the CRP storage area
  421. X    move.l    4,a6            ; Get ExecBase
  422. X    move.l    a5,-(sp)
  423. X    lea.l    1$,a5            ; Get the start of the supervisor code
  424. X    CALLSYS    Supervisor
  425. X    movem.l    (sp)+,a5        ; Give back registers
  426. X    rts
  427. X1$
  428. X    PMOVE_    (a0),crp        ; Just load the CRP register
  429. X    rte
  430. X
  431. X;======================================================================
  432. X;
  433. X;    This function returns the MMU TC register.  It assumes a 68020 
  434. X;    system with MMU, or a 68030 based system (eg, test for MMU before
  435. X;    you call this, or you wind up in The Guru Zone).  
  436. X;
  437. X;    ULONG GetTC()
  438. X;
  439. X;======================================================================
  440. X
  441. X_GetTC:
  442. X    move.l    4,a6            ; Get ExecBase
  443. X    move.l    a5,-(sp)
  444. X    subq.l    #4,sp            ; Make a place to dump TC
  445. X    move.l    sp,a0
  446. X    lea.l    1$,a5            ; Get the start of the supervisor code
  447. X    CALLSYS    Supervisor
  448. X    move.l    (sp),d0            ; Here's the result
  449. X    addq.l    #4,sp
  450. X    move.l    (sp)+,a5
  451. X    rts
  452. X1$
  453. X    PMOVE_    tc,(a0)            ; Just get the TC register
  454. X    rte
  455. X
  456. X;======================================================================
  457. X;
  458. X;    This function sets the MMU TC register.  It assumes a 68020 
  459. X;    system with MMU, or a 68030 based system (eg, test for MMU before
  460. X;    you call this, or you wind up in The Guru Zone).  
  461. X;
  462. X;    void SetTC(ULONG)
  463. X;
  464. X;======================================================================
  465. X
  466. X_SetTC:
  467. X    lea.l    4(sp),a0        ; Get address of our new TC value
  468. X    move.l    4,a6            ; Get ExecBase
  469. X    move.l    a5,-(sp)
  470. X    lea.l    1$,a5            ; Get the start of the supervisor code
  471. X     CALLSYS    Supervisor
  472. X    move.l    (sp)+,a5
  473. X    rts
  474. X1$
  475. X    PMOVE_    (a0),tc            ; Just set the TC register
  476. X    rte
  477. X
  478. END_OF_FILE
  479. if test 5383 -ne `wc -c <'control.i'`; then
  480.     echo shar: \"'control.i'\" unpacked with wrong size!
  481. fi
  482. # end of 'control.i'
  483. fi
  484. if test -f 'diskio.c' -a "${1}" != "-c" ; then 
  485.   echo shar: Will not clobber existing file \"'diskio.c'\"
  486. else
  487. echo shar: Extracting \"'diskio.c'\" \(5075 characters\)
  488. sed "s/^X//" >'diskio.c' <<'END_OF_FILE'
  489. X/*
  490. X    SetCPU V1.60
  491. X    by Dave Haynie, April 13, 1990
  492. X    Released to the Public Domain
  493. X
  494. X    DISKIO.C MODULE
  495. X
  496. X    This module is responsible for fetching ROM images from various
  497. X    kinds of disks and files.
  498. X*/
  499. X
  500. X#include "setcpu.h"
  501. X
  502. X/* This function allocates a ROM image from a KickStart disk for KICKROM. */
  503. X
  504. X#define ColorShift(x)    (LONG)((((x)&0xf)+1)%15)
  505. X
  506. Xstruct systag *AllocKSImage(name)
  507. Xchar *name;
  508. X{
  509. X   struct systag *tag = NULL;
  510. X   ULONG *buf = NULL, blocks;
  511. X   char *ptr;
  512. X   LONG unit, i, r = 0x0004L, g = 0x0008L, b = 0x000cL,start;
  513. X   struct MsgPort *port = NULL;
  514. X   struct IOStdReq *req = NULL;
  515. X   struct Window *hand = NULL;
  516. X   BOOL devok = FALSE;
  517. X   
  518. X /* Then we expect it to be a kickstart disk, so we check out the device,
  519. X    the disk, etc.  If all goes well, we'll be in business. */
  520. X
  521. X   if ((unit = CheckTDDev(name)) == -1L) {
  522. X      LoadErr = 16;
  523. X      goto fail;
  524. X   }
  525. X   
  526. X  /* This is the stuff that need opening... */
  527. X   port = (struct MsgPort *) CreatePort("diskreq.port",0L);   
  528. X   if (port) req = CreateStdIO(port,0L);
  529. X   if (req) devok = !OpenDevice("trackdisk.device",unit,(struct IORequest *)req,0L);
  530. X   if (devok) buf = (ULONG *)AllocMem(512L,MEMF_CHIP);
  531. X   if (!port || !req || !devok || !buf) goto fail;
  532. X
  533. X  /* Make sure we're a kick disk. */
  534. X   hand = CoolHand();
  535. X   while ((ReadBuf((char *)buf,0L,req) != READOK) || 
  536. X          !strniequ("KICK",(char *)buf,4))
  537. X      Delay(150L);
  538. X      
  539. X  /* Check the size of this kickstart. */
  540. X
  541. X   if (!(tag = AllocMem(SizeOf(struct systag),0L))) goto fail;
  542. X   start = 0;
  543. X   do {
  544. X      if (ReadBuf((char *)buf,++start,req) != READOK) goto fail;
  545. X      ptr = (char *)SizeROM(tag,buf,TRUE);
  546. X   } while (ptr == NULL && start < 32L);
  547. X
  548. X   if (!ptr) goto fail;
  549. X
  550. X   blocks = tag->romsize/512L;
  551. X         
  552. X  /* Looks like we're in shape to get the actual system. */
  553. X
  554. X   SetRGB4(&(hand->WScreen->ViewPort),2L,r,g,b);
  555. X   for (i = 1; i <= blocks; ++i) {
  556. X      if (ReadBuf((char *)buf,i,req) != READOK) break;
  557. X      MemCopy((char *)buf,ptr,512L);
  558. X      ptr += 512L;
  559. X      r = ColorShift(r);
  560. X      g = ColorShift(g);
  561. X      b = ColorShift(b);
  562. X
  563. X      SetRGB4(&(hand->WScreen->ViewPort),2L,r,g,b);
  564. X   }
  565. X   LoadErr = 0;
  566. X   
  567. Xdone:
  568. X   if (buf) FreeMem((char *)buf,512L);
  569. X   if (devok) {
  570. X      MotorOff(req);
  571. X      CloseDevice((struct IORequest *)req);
  572. X   }
  573. X   if (req)  DeleteStdIO(req);
  574. X   if (port) DeletePort(port);
  575. X   return tag;
  576. X   
  577. Xfail:
  578. X   if (tag) {
  579. X      FreeMem(tag,SizeOf(struct systag));
  580. X      tag = NULL;
  581. X   }
  582. X   goto done;
  583. X}
  584. X
  585. X/* This function allocates a ROM image from an AmigaDOS file for either
  586. X   KICKROM or FASTROM. */
  587. X
  588. Xstruct systag *AllocFILEImage(name)
  589. Xchar *name;
  590. X{
  591. X   struct systag *tag = NULL;
  592. X   ULONG *rom = NULL, space[2], check;
  593. X   BPTR file = NULL;
  594. X   struct FileInfoBlock *fib;
  595. X   
  596. X  /* First off, let's check out this here file. */
  597. X  
  598. X   if (!(fib = AllocMem(SizeOf(struct FileInfoBlock),0L))) goto fail;
  599. X   if (!(file = Lock(name,ACCESS_READ))) {
  600. X      LoadErr = 24;
  601. X      goto fail;
  602. X   }
  603. X   Examine(file,fib);
  604. X   UnLock(file);
  605. X   file = NULL;   
  606. X   if (fib->fib_DirEntryType > 0L || !(file = Open(name,MODE_OLDFILE))) {
  607. X      LoadErr = 24;
  608. X      goto fail;
  609. X   }
  610. X   
  611. X  /* Try to find a sensible ROM header, either its a plain ROM, or the one
  612. X     with the extra sizing info at the head. */
  613. X
  614. X   Read(file,(char *)space,8L);
  615. X   if (space[0])
  616. X      Seek(file,0L,OFFSET_BEGINNING);
  617. X   else {
  618. X      check = space[1];
  619. X      Read(file,(char *)space,8L);
  620. X      Seek(file,8L,OFFSET_BEGINNING);
  621. X   }
  622. X
  623. X  /* Let's allocate the space I need.  KICKROMs don't use a disk image
  624. X     directly, so they don't need an MMU table and don't care about any special
  625. X     alignment.  FASTROMs read from disk do care, so I will align this image. */
  626. X  
  627. X   SmartlyGetRange();
  628. X   if (!(tag = AllocAligned(SizeOf(struct systag),8L))) goto fail;
  629. X
  630. X   if (!(rom = SizeROM(tag,space,TRUE))) {
  631. X      LoadErr == 22;
  632. X      goto fail;
  633. X   }
  634. X   if (tag->romsize != Read(file,(char *)rom,tag->romsize)) {
  635. X      LoadErr = 23;
  636. X      goto fail;
  637. X   }
  638. X   Close(file);
  639. X   FreeMem(fib,SizeOf(struct FileInfoBlock));
  640. X   return tag;
  641. X
  642. Xfail:
  643. X   if (file) Close(file);
  644. X   if (fib) FreeMem(fib,SizeOf(struct FileInfoBlock));   
  645. X   if (rom) FreeMem(rom,tag->romsize);
  646. X   if (tag) FreeMem(tag,SizeOf(struct systag));
  647. X   return NULL;   
  648. X}
  649. X
  650. X/* This function gets a ROM image from disk; in temporary unaligned memory
  651. X   for a KICKROM image, permanent aligned memory for a FASTROM image. */
  652. X
  653. Xstruct systag *AllocDISKImage(type,name)
  654. XUWORD type;
  655. Xchar *name;
  656. X{
  657. X   struct systag *tag;
  658. X   ULONG *table;
  659. X
  660. X  /* Reset the error code. */
  661. X   LoadErr = 0;
  662. X
  663. X  /* Let's check out this here file.  It's easy to tell; we want a FILE
  664. X     image if we aren't passed a KICK_ROM request with a device name. */
  665. X  
  666. X   if (type == ROM_FAST || name[strlen(name)-1] != ':') {
  667. X      tag = AllocFILEImage(name);
  668. X      if ((tag->romtype = type) == ROM_FAST) {
  669. X         FindWrap(tag);
  670. X         if (!(table = AllocAligned(tag->tablesize+4,TABROUND))) return NULL;
  671. X         tag->maintable = table;
  672. X         FillBasicTable(tag,FALSE);
  673. X      }
  674. X      return tag;
  675. X   } 
  676. X     
  677. X   return AllocKSImage(name);
  678. X}
  679. END_OF_FILE
  680. if test 5075 -ne `wc -c <'diskio.c'`; then
  681.     echo shar: \"'diskio.c'\" unpacked with wrong size!
  682. fi
  683. # end of 'diskio.c'
  684. fi
  685. if test -f 'expdev.c' -a "${1}" != "-c" ; then 
  686.   echo shar: Will not clobber existing file \"'expdev.c'\"
  687. else
  688. echo shar: Extracting \"'expdev.c'\" \(6166 characters\)
  689. sed "s/^X//" >'expdev.c' <<'END_OF_FILE'
  690. X/*
  691. X    SetCPU V1.60
  692. X    by Dave Haynie, April 13, 1990
  693. X    Released to the Public Domain
  694. X
  695. X    EXPANSION DEVICE MODULE
  696. X    
  697. X    This module maintains the code used to detect and translate
  698. X    a given expansion device.
  699. X*/
  700. X
  701. X#include "setcpu.h"
  702. X
  703. X/* ====================================================================== */
  704. X
  705. X/* Stuff I need for this module. */
  706. X
  707. Xchar *malloc();
  708. Xint sscanf();
  709. X
  710. X/* ====================================================================== */
  711. X
  712. X/* This section manages devices with on-board ROM.  The actual 
  713. X   implementation of this stuff is pretty well hidden in this
  714. X   module. */
  715. X   
  716. X/* This structure manages the expansion devices that we know about. */
  717. X
  718. Xstruct ExpDev {
  719. X   struct Node node;
  720. X   ULONG manuf;
  721. X   ULONG board;
  722. X   ULONG size;
  723. X   ULONG romoffset;
  724. X   ULONG romsize;
  725. X};
  726. X   
  727. X/* Here's the list of all the devices we know about. */
  728. X
  729. Xstatic struct List Devices = 
  730. X   {(struct Node *)&Devices.lh_Tail,NULL,(struct Node *)&Devices.lh_Head,0,0};
  731. X
  732. Xstatic struct ExpDev *CurrentDevice = NULL;
  733. X
  734. X/* This function reads the list of expansion devices from the given file.
  735. X   The file should contain data for one device per line, with the 
  736. X   following format:
  737. X   
  738. X       MANUF    PROD    SIZE    START    LENGTH    id-string
  739. X       
  740. X   Except for the last field, all numbers are integers, which may be 
  741. X   expressed as decimal or hexidecimal.  The last field is a text
  742. X   string which may contain any information.  It's very likely that
  743. X   the line for each device will have to be supplied by the maker
  744. X   of any device, since there's no way to figure out if a device's
  745. X   ROM is on the same MMU page as an important I/O register which
  746. X   shouldn't ever be translated.  The description I use for the Amiga
  747. X   2090A controller is:
  748. X   
  749. X      0x202 0x01 0x10000 0x8000 0x4000 CBM 2090A Disk Controller
  750. X
  751. X   The actual fields are:
  752. X   
  753. X    MANUF        The Manufacturer's code for the PIC
  754. X    PROD        The Product code for the PIC
  755. X    SIZE        The configured size of the PIC
  756. X    START        The offset from the PIC base for the start of ROM
  757. X    LENGTH        The length of the ROM    
  758. X    id-string    Whatever the hell you want
  759. X*/
  760. X
  761. XLONG ReadExpDevs(name)
  762. Xchar *name;
  763. X{
  764. X   FILE *file;
  765. X   char buf[256],msg[256];
  766. X   struct ExpDev *ed;
  767. X   int len,i;
  768. X   
  769. X   if (!(file = fopen(name,"r"))) return FALSE;
  770. X   
  771. X   while (fgets(buf,256,file)) {
  772. X      ed = (struct ExpDev *)malloc(sizeof(struct ExpDev));
  773. X      if (sscanf(buf,"%lx%lx%lx%lx%lx%s",&ed->manuf,&ed->board,&ed->size,
  774. X                 &ed->romoffset,&ed->romsize,msg) >= 5) {
  775. X         if (len = strlen(msg)) {
  776. X            ed->node.ln_Name = (char *)malloc(len+1);
  777. X            for (i = 0; i <= len; ++i)
  778. X               ed->node.ln_Name[i] = (msg[i] == '_')?' ':msg[i];
  779. X         }
  780. X         if (ed->romsize = ((ed->romsize/DEVROUND)*DEVROUND))
  781. X            AddHead(&Devices,(struct Node *)ed);
  782. X         else
  783. X            free(ed);
  784. X      } else
  785. X         free(ed);
  786. X   }
  787. X   fclose(file);
  788. X   CurrentDevice = (struct ExpDev *)Devices.lh_Head;
  789. X   return TRUE;
  790. X}
  791. X
  792. X/* ====================================================================== */
  793. X
  794. X/* This function returns the ROM information I'll need for a given 
  795. X   expansion device.  Because of some Commodore screwups, the A2090A
  796. X   appears the same device as other boards like the Commodore RAM
  797. X   board.  So I have the size passed as well, as a consistency 
  798. X   check.  The returned ExpROMData structure is allocated here, and
  799. X   can be freed when no longer needed. */
  800. X    
  801. Xstruct ExpROMData *GetExpROM() 
  802. X{
  803. X   struct ConfigDev *cd;
  804. X   struct DiagArea *da;   
  805. X   struct ExpROMData *ed;
  806. X   
  807. X   if (!CurrentDevice || !ExpansionBase) return NULL;
  808. X   cd = FindConfigDev(NULL,CurrentDevice->manuf,CurrentDevice->board);
  809. X
  810. X   while (cd) {
  811. X      if (((ULONG)cd->cd_BoardSize == CurrentDevice->size) && 
  812. X          (cd->cd_Rom.er_Type & ERTF_DIAGVALID)) {
  813. X         da = (struct DiagArea *)(((ULONG)cd->cd_BoardAddr)+((ULONG)cd->cd_Rom.er_InitDiagVec));
  814. X
  815. X        /* This is just a sanity check to make sure we really use the
  816. X           ROM out on this card -- a nybble or byte wide ROM will be in
  817. X           RAM already. */
  818. X         if ((da->da_Config & DAC_BUSWIDTH) == DAC_WORDWIDE)  {
  819. X            ed = (struct ExpROMData *)AllocMem(SizeOf(struct ExpROMData),MEMF_CLEAR);
  820. X            ed->ROMbase = ((ULONG)cd->cd_BoardAddr) + CurrentDevice->romoffset;
  821. X            ed->ROMsize = CurrentDevice->romsize;
  822. X            ed->imagebase = NULL;
  823. X            ed->tablebase = NULL;
  824. X            ed->name = (char *)AllocMem((ULONG)
  825. X                               strlen(CurrentDevice->node.ln_Name)+1,0L);
  826. X            strcpy(ed->name,CurrentDevice->node.ln_Name);
  827. X            ++CurrentDevice;
  828. X            return ed;
  829. X         }
  830. X      }
  831. X      cd = FindConfigDev(cd,CurrentDevice->manuf,CurrentDevice->board); 
  832. X   }
  833. X   CurrentDevice = (struct ExpDev *)CurrentDevice->node.ln_Succ;
  834. X   return NULL;
  835. X}
  836. X
  837. X/* This function removes a CardROMFile generated I/O ROM table list. */
  838. X
  839. Xvoid FreeExpROM(emem)
  840. Xstruct ExpROMData *emem;
  841. X{
  842. X   struct ExpROMData *edel;
  843. X
  844. X   while (emem) {
  845. X      edel = emem;
  846. X      emem = emem->next;
  847. X      FreeMem(edel->imagebase,edel->ROMsize);
  848. X      FreeMem(edel->name,(ULONG)strlen(edel->name)+1);
  849. X      FreeMem(edel,SizeOf(struct ExpROMData));
  850. X   }
  851. X}
  852. X
  853. X/* ====================================================================== */
  854. X
  855. X/* This routine is called to configure the system devices without calling any
  856. X   ROM routines that could possibly goober up on older OS releases.  Other
  857. X   than skipping ROMs, this should do the same thing as the ConfigChain()
  858. X   function in expansion.library. */
  859. X   
  860. Xvoid SafeConfigDevs()
  861. X{
  862. X   struct ConfigDev *cd;
  863. X   char *base = (char *)0xe80000;
  864. X
  865. X   if (!ExpansionBase) return;
  866. X
  867. X   /* Should also loop only as long as 
  868. X         !(ExpansionBase->eb_Flags & EBB_CLOGGED), 
  869. X      but I don't know what EBB_CLOGGED is yet.. */
  870. X
  871. X   while (cd = AllocConfigDev()) {
  872. X      if (ReadExpansionRom(base,cd)) {
  873. X         FreeConfigDev(cd); 
  874. X         break;
  875. X      }
  876. X
  877. X     /* Got it, let's get rid of any ROM critters. */
  878. X      cd->cd_Rom.er_Type &= ~ERTF_DIAGVALID;
  879. X
  880. X    /* Now adding the board should be safe! */
  881. X      if (ConfigBoard(base,cd)) {
  882. X         FreeConfigDev(cd);
  883. X         break;
  884. X      }
  885. X      AddConfigDev(cd);
  886. X   }
  887. X}
  888. X
  889. END_OF_FILE
  890. if test 6166 -ne `wc -c <'expdev.c'`; then
  891.     echo shar: \"'expdev.c'\" unpacked with wrong size!
  892. fi
  893. # end of 'expdev.c'
  894. fi
  895. if test -f 'idents.a' -a "${1}" != "-c" ; then 
  896.   echo shar: Will not clobber existing file \"'idents.a'\"
  897. else
  898. echo shar: Extracting \"'idents.a'\" \(6346 characters\)
  899. sed "s/^X//" >'idents.a' <<'END_OF_FILE'
  900. X;======================================================================
  901. X;
  902. X;    SetCPU V1.60
  903. X;    by Dave Haynie, April 13, 1990
  904. X;    Released to the Public Domain
  905. X;
  906. X;    IDENTS.A MODULE
  907. X;
  908. X;    This module contains the functions that ID the CPU, MMU, and FPU
  909. X;    type indtalled in the system.
  910. X;
  911. X;======================================================================
  912. X
  913. X    include "setcpu.i"
  914. X
  915. X    cseg
  916. X
  917. X    xdef    _GetCPUType    ; ID the CPU
  918. X    xdef    _GetMMUType    ; ID the MMU
  919. X    xdef    _GetFPUType    ; ID the FPU
  920. X
  921. X;======================================================================
  922. X;
  923. X;    This routine checks CPU flags early in ExecBase for extended
  924. X;    CPUs that test as a 68020 under 1.3.  If these flags are set,
  925. X;    the actual CPU/MMU type test can be skipped.
  926. X;
  927. X;======================================================================
  928. X
  929. XTestFlags:
  930. X    moveq.l    #0,d0
  931. X    btst.b    #AFB_68040,ATNFLGS(a6)    ; Does the OS think an '040 is here?
  932. X    beq NoEarly40
  933. X    move.l    #68040,d0
  934. X    rts
  935. XNoEarly40:
  936. X    btst.b    #AFB_68030,ATNFLGS(a6)    ; Does the OS think an '030 is here?
  937. X    beq    NoEarly30
  938. X    move.l    #68030,d0        ; Sure does...
  939. XNoEarly30:
  940. X    rts
  941. X
  942. X
  943. X;======================================================================
  944. X;
  945. X;    This function returns the type of the CPU in the system as a
  946. X;    longword: 68000, 68010, 68020, or 68030.  The testing must be done
  947. X;    in reverse order, in that any higher CPU also has the bits set for
  948. X;    a lower CPU.  Also, since 1.3 doesn't recognize the 68030, if I
  949. X;    find the 68020 bit set, I always check for the presence of a 
  950. X;    68030.
  951. X;
  952. X;    This routine should be the first test routine called under 1.2
  953. X;    and 1.3.
  954. X;
  955. X;    ULONG GetCPUType();
  956. X;
  957. X;======================================================================
  958. X
  959. X_GetCPUType:
  960. X    move.l    4,a6            ; Get ExecBase
  961. X    jsr    TestFlags        ; Check extended CPU types
  962. X    cmp.l    #0,d0
  963. X    beq    CPURealTest
  964. X    rts
  965. XCPURealTest:
  966. X    movem.l    a4/a5,-(sp)        ; Save this register
  967. X    btst.b    #AFB_68020,ATNFLGS(a6)    ; Maybe a 68020
  968. X    bne    FindReal32
  969. X    btst.b    #AFB_68010,ATNFLGS(a6)    ; Maybe a 68010?
  970. X    bne    Found10
  971. X    move.l    #68000,d0        ; Just a measley '000
  972. X    movem.l    (sp)+,a4/a5
  973. X    rts
  974. XFound10:
  975. X    move.l    #68010,d0        ; Yup, we're an '010
  976. X    movem.l    (sp)+,a4/a5
  977. X    rts
  978. XFindReal32:
  979. X    move.w    LIB_VERSION(a6),d0    ; Are we in 2.0?
  980. X    cmp.w    #36,d0            ; If so, we don't need to test
  981. X    bge    No40
  982. X
  983. X    lea.l    SuperGCT,a5        ; Get the start of the supervisor code
  984. X    CALLSYS    Supervisor
  985. X
  986. X    btst.l    #CIB_BURST,d0        ; Do we have a set burst bit?
  987. X    beq    No30
  988. X    move.l    #68030,d0        ; It's a 68030
  989. X    bset.b    #AFB_68030,ATNFLGS(a6)
  990. X    movem.l    (sp)+,a4/a5
  991. X    rts
  992. XNo30:    
  993. X    btst.l    #CIB_ENABLE40,d1    ; Do we have 040 cache enable?
  994. X    beq    No40
  995. X    move.l    #68040,d0        ; It's a 68040
  996. X    bset.b    #AFB_68040,ATNFLGS(a6)
  997. X    movem.l    (sp)+,a4/a5
  998. X    rts
  999. XNo40:
  1000. X    move.l    #68020,d0        ; Guess we're a plain old '020
  1001. X    movem.l    (sp)+,a4/a5
  1002. X    rts
  1003. X
  1004. X    ; This routine tries to set a few interesting CACR bits, and
  1005. X    ; returns the actual register value that took in d0.
  1006. XSuperGCT:
  1007. X    MOVEC_    cacr,d1            ; Get the cache register
  1008. X    move.l    d1,d0            ; Make a copy
  1009. X    bset.l    #CIB_BURST,d0        ; Set the inst burst bit 030
  1010. X    bclr.l    #CIB_ENABLE,d0        ; Clear the inst cache bit 030
  1011. X    bset.l    #CIB_ENABLE40,d0    ; Set the inst cache bit 040
  1012. X    MOVEC_    d0,cacr            ; Try to set the CACR
  1013. X    MOVEC_    cacr,d0            ; Save the real value
  1014. X    MOVEC_    d1,cacr            ; Restore it
  1015. X    rte
  1016. X
  1017. X;======================================================================
  1018. X;
  1019. X;    This function returns 0L if the system contains no MMU, 
  1020. X;    68851L if the system does contain an 68851, or the CPU number
  1021. X;    for CPUs with integral CPUs.
  1022. X;
  1023. X;    This routine seems to lock up on at least some CSA 68020 
  1024. X;    boards, though it runs just fine on those from Ronin and 
  1025. X;    Commodore, as well as all 68030 boards it's been tested on.
  1026. X;
  1027. X;    ULONG GetMMUType()
  1028. X;
  1029. X;======================================================================
  1030. X
  1031. X_GetMMUType:
  1032. X    move.l    4,a6            ; Get ExecBase
  1033. X    jsr    TestFlags        ; Check extended CPU types
  1034. X    cmp.l    #0,d0
  1035. X    beq    MMURealTest
  1036. X    rts
  1037. X
  1038. X    ; For any other machine, a real test must be done.  The test will
  1039. X    ; try an MMU instruction.  The instruction will fail unless we're
  1040. X    ; on a "bogus MMU" system, where the FPU responds as an MMU.
  1041. XMMURealTest:
  1042. X    movem.l    a3/a4/a5,-(sp)        ; Save this stuff
  1043. X    move.l    #0,a1    
  1044. X    CALLSYS    FindTask        ; Call FindTask(0L)
  1045. X    move.l    d0,a3
  1046. X
  1047. X    move.l    TC_TRAPCODE(a3),a4    ; Change the exception vector
  1048. X    move.l    #MMUTraps,TC_TRAPCODE(a3)
  1049. X    
  1050. X    move.l    #-1,d0            ; Try to detect undecode FPU
  1051. X    subq.l    #4,sp            ; Get a local variable
  1052. X    PMOVE_    tc,(sp)            ; Let's try an MMU instruction
  1053. X    addq.l    #4,sp            ; Return that local
  1054. X    move.l    a4,TC_TRAPCODE(a3)    ; Reset exception stuff
  1055. X    movem.l    (sp)+,a3/a4/a5        ; and return the registers
  1056. X    rts
  1057. X
  1058. X    ; This is the exception code.  No matter what machine we're on,
  1059. X    ; we get an exception.  If the MMU's in place, we should get a
  1060. X    ; privilige violation; if not, an F-Line emulation exception.
  1061. XMMUTraps:
  1062. X    move.l    (sp)+,d0        ; Get Amiga supplied exception #
  1063. X    cmpi    #11,d0            ; Is it an F-Line?
  1064. X    beq    MMUNope            ; If so, go to the fail routine
  1065. X    move.l    #68851,d0        ; We have MMU
  1066. X    addq.l    #4,2(sp)        ; Skip the MMU instruction
  1067. X    rte
  1068. XMMUNope:
  1069. X    moveq.l    #0,d0            ; It dinna woik,
  1070. X    addq.l    #4,2(sp)        ; Skip the MMU instruction
  1071. X    rte
  1072. X
  1073. X;======================================================================
  1074. X;
  1075. X;    This function returns the type of the FPU in the system as a
  1076. X;    longword: 0 (no FPU), 68881, or 68882.
  1077. X;
  1078. X;    ULONG GetFPUType();
  1079. X;
  1080. X;======================================================================
  1081. X
  1082. X_GetFPUType:
  1083. X    move.l    4,a6            ; Get ExecBase
  1084. X    btst.b    #AFB_68040,ATNFLGS(a6)    ; Is there a 68040 here?
  1085. X    beq    Look4FPU
  1086. X    move.l    #68040,d0
  1087. X    rts
  1088. XLook4FPU:    
  1089. X    move.l    a5,-(sp)        ; Save this register
  1090. X    btst.b    #AFB_68881,ATNFLGS(a6)    ; Does the OS think an FPU is here?
  1091. X    bne    FPUHere
  1092. X    moveq.l    #0,d0            ; No FPU here, dude
  1093. X    move.l    (sp)+,a5        ; Give back the register
  1094. X    rts
  1095. XFPUHere:
  1096. X    btst.b    #AFB_68882,ATNFLGS(a6)    ; How's about an '882?
  1097. X    beq    FPUTest
  1098. X    move.l    #68882,d0        ; Sure does...
  1099. X    move.l    (sp)+,a5
  1100. X    rts
  1101. XFPUTest:
  1102. X    move.w    LIB_VERSION(a6),d0    ; Are we in 2.0?
  1103. X    cmp.w    #36,d0            ; If so, we don't need to test
  1104. X    blt    FPUTrap
  1105. X    move.l    #68881,d0
  1106. X    move.l    (sp)+,a5
  1107. X    rts
  1108. XFPUTrap:
  1109. X    lea.l    FPUSuper,a5        ; Get the start of the supervisor code
  1110. X    CALLSYS    Supervisor
  1111. X    move.l    (sp)+,a5        ; Give back registers
  1112. X    rts
  1113. XFPUSuper:
  1114. X    move.l    #68881,d0        ; Assume we're a 68881
  1115. X    fsave    -(sp)            ; Test and check
  1116. X    moveq.l    #0,d1
  1117. X    move.b    1(sp),d1        ; Size of this frame
  1118. X    cmpi    #$18,d1
  1119. X    beq FPU81
  1120. X    move.l    #68882,d0        ; It's a 68882
  1121. X    bset.b    #AFB_68882,ATNFLGS(a6)
  1122. XFPU81:
  1123. X    frestore (sp)+            ; Restore the stack
  1124. X    rte
  1125. X
  1126. X    end
  1127. X
  1128. END_OF_FILE
  1129. if test 6346 -ne `wc -c <'idents.a'`; then
  1130.     echo shar: \"'idents.a'\" unpacked with wrong size!
  1131. fi
  1132. # end of 'idents.a'
  1133. fi
  1134. if test -f 'makefile' -a "${1}" != "-c" ; then 
  1135.   echo shar: Will not clobber existing file \"'makefile'\"
  1136. else
  1137. echo shar: Extracting \"'makefile'\" \(464 characters\)
  1138. sed "s/^X//" >'makefile' <<'END_OF_FILE'
  1139. X######################################################################
  1140. X#
  1141. X# Makefile for SetCPU V1.6
  1142. X#
  1143. X######################################################################
  1144. X
  1145. X.a.o:
  1146. X    as -o $@ $*.a
  1147. X
  1148. XCFLAGS    = +x5
  1149. XLFLAGS    = -lm -lc
  1150. X
  1151. XCOBJS    = expdev.o memory.o mmu.o coolhand.o misc.o diskio.o setcpu.o
  1152. XAOBJS    = idents.o control.o reboot.o other.o
  1153. XOBJS    = $(AOBJS) $(COBJS)
  1154. X
  1155. XSetCPU:        $(OBJS) setcpu.o 
  1156. X        ln $(OBJS) -o SetCPU $(LFLAGS)
  1157. X
  1158. X$(COBJS):    setcpu.h
  1159. X
  1160. X$(AOBJS):    setcpu.i
  1161. END_OF_FILE
  1162. if test 464 -ne `wc -c <'makefile'`; then
  1163.     echo shar: \"'makefile'\" unpacked with wrong size!
  1164. fi
  1165. # end of 'makefile'
  1166. fi
  1167. if test -f 'misc.c' -a "${1}" != "-c" ; then 
  1168.   echo shar: Will not clobber existing file \"'misc.c'\"
  1169. else
  1170. echo shar: Extracting \"'misc.c'\" \(5481 characters\)
  1171. sed "s/^X//" >'misc.c' <<'END_OF_FILE'
  1172. X/*
  1173. X    SetCPU V1.60
  1174. X    by Dave Haynie, April 13, 1990
  1175. X    Released to the Public Domain
  1176. X
  1177. X    MISC.C MODULE
  1178. X    
  1179. X    This module is responsible for managing ROM image patchs.
  1180. X*/
  1181. X
  1182. X#include "setcpu.h"
  1183. X
  1184. X
  1185. X/* ====================================================================== */
  1186. X
  1187. X/* This replaces the Lattice "stricmp()" function, plus it's a better form
  1188. X   for my needs here. */
  1189. X   
  1190. XLONG striequ(s1,s2)
  1191. Xchar *s1,*s2;
  1192. X{
  1193. X   LONG aok = FALSE;
  1194. X   
  1195. X   while (*s1 && *s2 && (aok = (*s1++ & 0xdf) == (*s2++ & 0xdf)));
  1196. X   return (LONG) (!*s1 && !*s2 && aok);
  1197. X}
  1198. X
  1199. XLONG strniequ(s1,s2,n)
  1200. Xchar *s1,*s2;
  1201. Xunsigned n;
  1202. X{
  1203. X   LONG aok = FALSE;
  1204. X   
  1205. X   while (n-- && *s1 && *s2 && (aok = (*s1++ & 0xdf) == (*s2++ & 0xdf)));
  1206. X   return aok;
  1207. X}
  1208. X
  1209. X/* ====================================================================== */
  1210. X
  1211. X/* The device I/O functions. */
  1212. X
  1213. X/* This routine turns off the motor. */
  1214. X
  1215. Xvoid MotorOff(req)
  1216. Xstruct IOStdReq *req;
  1217. X{
  1218. X   req->io_Length = 0L;
  1219. X   req->io_Command = TD_MOTOR;
  1220. X   (void)DoIO((struct IORequest *)req);
  1221. X}
  1222. X
  1223. X/* This function fills the buffer "buf" with the contents of the given
  1224. X   sector number.  Returns 0 if there's no error.  */
  1225. X
  1226. XBYTE ReadBuf(buf,sect,req)
  1227. Xchar *buf;
  1228. XLONG sect;
  1229. Xstruct IOStdReq *req;
  1230. X{
  1231. X   req->io_Length = 512L;
  1232. X   req->io_Data = (APTR) buf;
  1233. X   req->io_Command = CMD_READ;
  1234. X   req->io_Offset = (512L * sect);
  1235. X   (void)DoIO((struct IORequest *)req);
  1236. X   return req->io_Error;
  1237. X}
  1238. X
  1239. X/* This function takes in a DOS name, and returns either the 
  1240. X   trackdisk.device unit that it corresponds to, or -1L. */
  1241. X   
  1242. XLONG CheckTDDev(name)
  1243. Xchar *name;
  1244. X{
  1245. X   char *devname;
  1246. X   struct DosLibrary *dl;
  1247. X   struct RootNode *dr;
  1248. X   struct DosInfo *di;
  1249. X   struct DeviceNode *dev;
  1250. X   struct FileSysStartupMsg *start;
  1251. X   struct DosEnvec *env;
  1252. X
  1253. X   dl = (struct DosLibrary *)OpenLibrary("dos.library",0L);
  1254. X   dr = (struct RootNode *)dl->dl_Root;
  1255. X   di = (struct DosInfo *)BADDR(dr->rn_Info);
  1256. X   dev = (struct DeviceNode *)BADDR(di->di_DevInfo);
  1257. X   CloseLibrary((struct Library *)dl);
  1258. X
  1259. X  /* Next we find the device */
  1260. X   if (name[strlen(name)-1] == ':') name[strlen(name)-1] = '\0';
  1261. X
  1262. X   for (; dev != NULL; dev = (struct DeviceNode *)BADDR(dev->dn_Next)) {
  1263. X      if (dev->dn_Type != DLT_DEVICE) continue;
  1264. X      devname = (char *)BADDR(dev->dn_Name);
  1265. X      if (strniequ(name,devname+1,(unsigned)devname[0])) break;
  1266. X   }
  1267. X
  1268. X  /* Is it a valid trackdisk.device? */
  1269. X   if (!dev) return -1L;
  1270. X   if (!(start = (struct FileSysStartupMsg *)BADDR(dev->dn_Startup))) return -1L;
  1271. X   env = (struct DosEnvec *)BADDR(start->fssm_Environ);
  1272. X   if (env->de_BlocksPerTrack != 11L || env->de_LowCyl != 0L) return -1L;
  1273. X   devname = (char *)BADDR(start->fssm_Device);
  1274. X   if (!strniequ(devname+1,"trackdisk.device",16)) return -1L;
  1275. X
  1276. X   return start->fssm_Unit;
  1277. X}
  1278. X
  1279. X/* ====================================================================== */
  1280. X
  1281. X/* The patch manager stuff. */
  1282. X
  1283. X/* The "JSR address" opcode used for my patches. */
  1284. X
  1285. X#define JSR_OPCODE    0x4eb9
  1286. X
  1287. X/* These are for some string patches */
  1288. X
  1289. Xstatic char DiskS[] = "SALV to recover it! ";
  1290. X
  1291. X/* These are the V1.3 patches */
  1292. X
  1293. Xstruct pitem PL_345[] = {
  1294. X   { PT_KEYBOARD,0,0x2528a,  0L, NULL },        /* Keyboard... */
  1295. X   { PT_STRING,  0,0x3fe19, 20L, (UWORD *)DiskS },    /* "DiskDoctor" name */
  1296. X   { PT_END,     0,      0,  0L, NULL }
  1297. X};
  1298. X
  1299. Xstruct pitem PL_33180[] = {
  1300. X   { PT_KEYBOARD,0,0x2572a,  0L, NULL },        /* Keyboard... */
  1301. X   { PT_STRING,  0,0x3fe11, 20L, (UWORD *)DiskS },    /* "DiskDoctor" name */
  1302. X   { PT_END,     0,      0,  0L, NULL }
  1303. X};
  1304. X
  1305. X/* This is main system patch list. */
  1306. X
  1307. Xstruct patch SystemPatch[] = {
  1308. X   { &SystemPatch[1], &PL_345[0],34,5 },
  1309. X   { NULL, &PL_33180[0],33,180 }
  1310. X};
  1311. X
  1312. X/* This is a pointer to the base of the last applied patch, for making
  1313. X   patch links.  The structure of any applied allocated patch, such as
  1314. X   a JSR patch, is a link pointer, the actual patch size, and then the
  1315. X   patch code.  This lets any version of SetCPU remove allocated patches
  1316. X   from any other version, providing it can locate the tag. */
  1317. X
  1318. Xstruct MemChunk *lastpatch = NULL;
  1319. X
  1320. X/* This routine applys the patch */
  1321. X
  1322. XLONG AddPatch(rom,lst,tag)
  1323. XULONG rom;
  1324. Xstruct patch *lst;
  1325. Xstruct systag *tag;
  1326. X{
  1327. X   UWORD *kickver = (UWORD *)(0x100000C - ( * (ULONG *) 0xFFFFEC ));
  1328. X   UWORD *addr, *base;
  1329. X   struct pitem *item;
  1330. X   struct MemChunk *chunk;
  1331. X   LONG any = FALSE;
  1332. X
  1333. X   while (lst) {
  1334. X      if (lst->Version == kickver[0] && lst->Revision == kickver[1]) {
  1335. X         for (item = &lst->list[0]; item->Type != PT_END; ++item) {
  1336. X            any = TRUE;
  1337. X            switch (item->Type) {
  1338. X               case PT_IGNORE :
  1339. X                  break;
  1340. X               case PT_STRING :
  1341. X                  MemCopy(item->Code,(char *)(rom+item->Offset),item->Length);
  1342. X                  ++tag->patches;
  1343. X                  break;
  1344. X               case PT_JSR    :
  1345. X                  chunk = (struct MemChunk *)AllocMem(item->Length+14L,0L);
  1346. X                  chunk->mc_Next = lastpatch;
  1347. X                  lastpatch = chunk;
  1348. X                  chunk->mc_Bytes = item->Length+14L;
  1349. X                  addr = (UWORD *)(((ULONG)chunk)+8L);
  1350. X                  base = (UWORD *)(rom+item->Offset);
  1351. X                  MemCopy(base,addr,6L);
  1352. X                  base[0] = (UWORD)JSR_OPCODE;
  1353. X                  base[1] = (UWORD)(((ULONG)addr)>>16L);
  1354. X                  base[2] = (UWORD)(((ULONG)addr)&0x0ffff);
  1355. X                  MemCopy(item->Code,&addr[3],item->Length);
  1356. X                  ++tag->patches;
  1357. X                  break;
  1358. X            }
  1359. X         }
  1360. X      }
  1361. X      lst = lst->next;
  1362. X   }
  1363. X   return any;
  1364. X}
  1365. X
  1366. X
  1367. X
  1368. X
  1369. X
  1370. X
  1371. X
  1372. X
  1373. X
  1374. X
  1375. X
  1376. X
  1377. X
  1378. X
  1379. X
  1380. X
  1381. X
  1382. X
  1383. X
  1384. X
  1385. X
  1386. X
  1387. X
  1388. X
  1389. END_OF_FILE
  1390. if test 5481 -ne `wc -c <'misc.c'`; then
  1391.     echo shar: \"'misc.c'\" unpacked with wrong size!
  1392. fi
  1393. # end of 'misc.c'
  1394. fi
  1395. if test -f 'other.a' -a "${1}" != "-c" ; then 
  1396.   echo shar: Will not clobber existing file \"'other.a'\"
  1397. else
  1398. echo shar: Extracting \"'other.a'\" \(4879 characters\)
  1399. sed "s/^X//" >'other.a' <<'END_OF_FILE'
  1400. X;======================================================================
  1401. X;
  1402. X;    SetCPU V1.60
  1403. X;    by Dave Haynie, April 13, 1990
  1404. X;    Released to the Public Domain
  1405. X;
  1406. X;    OTHER.A MODULE
  1407. X;
  1408. X;    This module contains miscellaneous assembly functions that just
  1409. X;    didn't seem to fit in elsewhere.
  1410. X;
  1411. X;======================================================================
  1412. X
  1413. X    include "setcpu.i"
  1414. X
  1415. X    cseg
  1416. X
  1417. X;**********************************************************************
  1418. X;
  1419. X;    Some useful MMU functions.
  1420. X;
  1421. X**********************************************************************
  1422. X
  1423. X    xdef    _SetMMUTag    ; Sets up MMU from systag
  1424. X    xdef    _FlushATC    ; Flush MMU address translation cache
  1425. X
  1426. X;======================================================================
  1427. X;
  1428. X;    This function cleanly sets up a new MMU context.  It accepts a
  1429. X;    valid systag, and will first go to Supervisor more, turn off
  1430. X;    the current MMU setup, then set CRP and finally TC.  The reason
  1431. X;    this call is needed is that we need the OS alive to get to
  1432. X;    Supervisor mode.  Setting up a new MMU context would normally
  1433. X;    take three calls to Supervisor(), one to turn off the MMU
  1434. X;    (ROM dies...), two to set first the new CRP and then the new
  1435. X;    TC.
  1436. X;
  1437. X;    void SetMMUTag(struct systag *tag)
  1438. X;
  1439. X;======================================================================
  1440. X
  1441. X_SetMMUTag:
  1442. X    move.l    4(sp),a0        ; Get the systag where we can use it
  1443. X    move.l    4,a6            ; Get ExecBase
  1444. X    movem.l    a2/a5,-(sp)
  1445. X    move.l    a0,a2
  1446. X    lea.l    1$,a5            ; Get the start of the supervisor code
  1447. X     CALLSYS    Supervisor
  1448. X    movem.l    (sp)+,a2/a5        ; Give back registers
  1449. X    rts
  1450. X1$
  1451. X    lea.l    TAG_TC(a2),a0        ; Get TC register
  1452. X    lea.l    TAG_CRP_0(a2),a1    ; Get CRP register
  1453. X
  1454. X    and.l    #$7fffffff,(a0)        ; Turn off MMU
  1455. X    PMOVE_    (a0),tc    
  1456. X    or.l    #$80000000,(a0)
  1457. X    PMOVE_    (a1),crp        ; Load up the CRP value
  1458. X    PMOVE_    (a0),tc            ; MMU goes back on
  1459. X    rte
  1460. X
  1461. X;======================================================================
  1462. X;
  1463. X;    This function flushes the MMU Address Translation Cache.
  1464. X;
  1465. X;    void FlushATC(void)
  1466. X;
  1467. X;======================================================================
  1468. X
  1469. X_FlushATC:
  1470. X    move.l    4,a6            ; Get ExecBase
  1471. X    move.l    a5,-(sp)
  1472. X    lea.l    1$,a5            ; Get the start of the supervisor code
  1473. X    CALLSYS    Supervisor
  1474. X    movem.l    (sp)+,a5        ; Give back registers
  1475. X    rts
  1476. X1$
  1477. X    PFLUSHA_            ; Flush the ATC
  1478. X    rte
  1479. X
  1480. X;**********************************************************************
  1481. X;
  1482. X;    This section contains the keyboad patch routine.
  1483. X;
  1484. X;**********************************************************************
  1485. X
  1486. X    xdef    _KeyCode    ; Start of the keyboard patch
  1487. X    xdef    _KeyCodeSize    ; Size of the keyboard patch
  1488. X    xdef    _SetKeyDelay    ; Set keyboard count parameter
  1489. X
  1490. X;======================================================================
  1491. X;
  1492. X;    This is the keyboard delay patch routine. 
  1493. X;
  1494. X;======================================================================
  1495. X
  1496. XKeyCode:
  1497. X    movem.l    d0/d1,-(sp)
  1498. XKeyOpt:
  1499. X    move.l    #12345678,d0
  1500. X1$    move.w    ANYCREG,d1
  1501. X    subq.l    #1,d0
  1502. X    bne    1$
  1503. X    movem.l    (sp)+,d0/d1
  1504. X    rts
  1505. XKeyCodeEnd:
  1506. X
  1507. X;======================================================================
  1508. X;
  1509. X;    This function programs the patch delay value.
  1510. X;
  1511. X;    void SetKeyDelay(ULONG)
  1512. X;
  1513. X;======================================================================
  1514. X
  1515. X_SetKeyDelay:
  1516. X    move.l    4(sp),d0        ; Get the delay value
  1517. X    lea    KeyOpt,a0        ; Get the location
  1518. X    move.l    d0,2(a0)        ; Set the value
  1519. X    rts
  1520. X
  1521. X_KeyCode:
  1522. X    dc.l    KeyCode
  1523. X_KeyCodeSize:
  1524. X    dc.l    KeyCodeEnd-KeyCode+1
  1525. X
  1526. X;**********************************************************************
  1527. X;
  1528. X;    This section contains the items used for the exception handler.
  1529. X;
  1530. X;**********************************************************************
  1531. X
  1532. X    xdef    _BerrCode    ; Start of the trap routine
  1533. X    xdef    _BerrCodeSize    ; Size of the trap routine
  1534. X
  1535. X;======================================================================
  1536. X;
  1537. X;    This is the exception handler for Bus Errors (level 2).  User
  1538. X;    code that misbehaves when the MMU is on can result in such an
  1539. X;    exception.  While the code needs to be fixed if this happens, 
  1540. X;    it's very possible that the code is not depending on it's random
  1541. X;    action; especially in the case of an accidental write to ROM
  1542. X;    space, which is harmless on a normally configured machine.
  1543. X;    This routine is never directly called by SetCPU.  Instead, it's
  1544. X;    copied into memory that's allocated as permanent by SetCPU.
  1545. X;
  1546. X;======================================================================
  1547. X
  1548. XSTATUS    EQU    $0a+4
  1549. X
  1550. XSR_DF    EQU    8
  1551. X
  1552. XBerrTrapCode:
  1553. X    move.l    d0,-(sp)        ; Save d0...
  1554. X    move.w    STATUS(sp),d0        ; Fetch exception status register
  1555. X
  1556. X    bclr.l    #SR_DF,d0        ; Clear the data fault bit
  1557. Xrepair:
  1558. X    move.w    d0,STATUS(sp)        ; Fix the status word
  1559. Xdone:
  1560. X    move.l    (sp)+,d0
  1561. X    rte
  1562. X
  1563. XBerrTrapEnd:
  1564. X
  1565. X;======================================================================
  1566. X;
  1567. X;    These give us the size and location of the Bus Error Code.
  1568. X;
  1569. X;======================================================================
  1570. X
  1571. X_BerrCode:
  1572. X    dc.l    BerrTrapCode
  1573. X_BerrCodeSize:
  1574. X    dc.l    BerrTrapEnd-BerrTrapCode+1
  1575. X
  1576. X    end
  1577. END_OF_FILE
  1578. if test 4879 -ne `wc -c <'other.a'`; then
  1579.     echo shar: \"'other.a'\" unpacked with wrong size!
  1580. fi
  1581. # end of 'other.a'
  1582. fi
  1583. if test -f 'reboot.a' -a "${1}" != "-c" ; then 
  1584.   echo shar: Will not clobber existing file \"'reboot.a'\"
  1585. else
  1586. echo shar: Extracting \"'reboot.a'\" \(5211 characters\)
  1587. sed "s/^X//" >'reboot.a' <<'END_OF_FILE'
  1588. X;======================================================================
  1589. X;
  1590. X;    SetCPU V1.60
  1591. X;    by Dave Haynie, April 13, 1990
  1592. X;    Released to the Public Domain
  1593. X;
  1594. X;    REBOOT.A MODULE
  1595. X;
  1596. X;    This module contains functions that do the clever reset magic
  1597. X;    needed for KickStart imaging.
  1598. X;
  1599. X;======================================================================
  1600. X
  1601. X    include "setcpu.i"
  1602. X
  1603. X    cseg
  1604. X
  1605. X    xdef    _RAMBoot    ; Effects the reboot into a RAM image
  1606. X    xdef    _BootCode    ; Actual main reboot code
  1607. X    xdef    _BootCodeSize    ; Size of this magic code
  1608. X    xdef    _CleanBoot    ; Boot back to system ROM, reset Exec
  1609. X    xdef    _ResetCode    ; Smart reset routine
  1610. X    xdef    _ResetCodeSize    ; Size of this magic code
  1611. X
  1612. X;======================================================================
  1613. X;
  1614. X;    This is the RAMBoot routine as called from C.  The C code has
  1615. X;    set up the tag structure with valid MMU data and a pointer to
  1616. X;    the main reset routine in safe memory.  The routine will fetch
  1617. X;    the systag from the stack, then call the safe routine in the
  1618. X;    supervisor mode.  That call is the last kernal call used; the
  1619. X;    reset routine itself doesn't use any ROM routines, so it can
  1620. X;    safely turn off the MMU before it goes to work, methinks.
  1621. X;
  1622. X;    void RAMBoot(struct systag *tag, LONG ClearExec,LONG Delay)
  1623. X;
  1624. X;======================================================================
  1625. X
  1626. X_RAMBoot:
  1627. X    move.l    4(sp),a2        ; Get the systag where we can use it
  1628. X    move.l    8(sp),d4        ; KeepExec?
  1629. X    move.l    12(sp),d5        ; Delay value
  1630. X    move.l    4,a6
  1631. X    lea.l    TrickyBits,a5        ; Get the supervisor code
  1632. X    CALLSYS    Supervisor        ; Go to supervisor mode
  1633. X    rts                ; We never get here!
  1634. X
  1635. X;======================================================================
  1636. X;
  1637. X;    This is the start of the supervisor portion of the reboot code.
  1638. X;    This code gets things in the registers the ChipRAM code 
  1639. X;    requires, loads up a reset routine into cache, freezes the
  1640. X;    cache, resets, waits for the CIA chips, and then calls the
  1641. X;    ChipRAM code portion which will turn the MMU on and jump to
  1642. X;    ROM's start address.
  1643. X;
  1644. X;    a2    SetCPU system tag
  1645. X;    a6    ExecBase
  1646. X;    d4    KeepExec Flag
  1647. X;    d5    Boot Delay
  1648. X;
  1649. X;======================================================================
  1650. X
  1651. XTrickyBits:
  1652. X    move.l    TAG_ROMSTART(a2),a4    ; Get the ROM jump address
  1653. X    move.l    TAG_RESETCODE(a2),a3    ; Get the ChipRAM based code
  1654. X    lea.l    TAG_CRP_0(a2),a1    ; Get CRP register
  1655. X    lea.l    TAG_TC(a2),a0        ; Get TC register
  1656. X
  1657. X    and.l    #$7fffffff,(a0)        ; Turn off MMU
  1658. X    PMOVE_    (a0),tc            ; -> $f010,$4000            
  1659. X    or.l    #$80000000,(a0)        ; Prep for startup
  1660. X    PMOVE_    (a1),crp        ; -> $f011,$4c00
  1661. X
  1662. X    cmp.l    #0,d4            ; If asked for, zap ExecBase good
  1663. X    bne    1$
  1664. X    moveq.l    #0,d0
  1665. X    move.l    d0,$4
  1666. X1$
  1667. X    move.l    #1,d1            ; Make sure inst cache is on!
  1668. X    MOVEC_    d1,cacr
  1669. X
  1670. X    move.l    #1,d3            ; First pass, no delay
  1671. X    lea.l    CacheRun,a6        ; Get the initial branch address
  1672. X
  1673. XRSTLoop:    
  1674. X    jmp (a6)
  1675. X
  1676. XRSTIt:
  1677. X    reset                ; Clobber the system
  1678. X    reset
  1679. X
  1680. XCacheRun:
  1681. X    move.w    ANYCREG,d1        ; Set a spell, take yer shoes off
  1682. X    subq.l    #1,d3
  1683. X    bne    CacheRun
  1684. X    move.b    #3,$bfe201        ; Turn off Amiga ROM Overlay
  1685. X    move.b    #2,$bfe001
  1686. X
  1687. X    cmp.l    a3,a6            ; Last time through?
  1688. X    beq    RSTLoop            ; If so, go back
  1689. X    
  1690. X    move.l    a3,a6            ; No?  Get the address,
  1691. X    move.l    d5,d3            ;          the delay
  1692. X    move.l    #3,d1            ;          freeze the cache
  1693. X    MOVEC_    d1,cacr            
  1694. X    bra    RSTIt            ; And Up to the reset stuff
  1695. X
  1696. X;======================================================================
  1697. X;
  1698. X;    This is the RAM reboot code, which is called to reset the 
  1699. X;    system into the new ROM, which is of course now in some magic
  1700. X;    and safe place.  The ROM's jump address in in A4 when this
  1701. X;    code is called, and the TC register is in A0.
  1702. X;
  1703. X;======================================================================
  1704. X
  1705. XRAMBootCode:
  1706. X    move.l    #0,d1            ; Turn all caches off
  1707. X    MOVEC_    d1,cacr
  1708. X    move.l    #10,d1            ; Let 'em know we're here
  1709. X1$
  1710. X    bchg    #1,$bfe001
  1711. X    move.l    #80000,d0
  1712. X2$    subq.l    #1,d0
  1713. X    bne    2$
  1714. X    dbra    d1,1$
  1715. X
  1716. X    PMOVE_    (a0),tc            ; Turn on the MMU
  1717. X    jmp    (a4)            ; Start up the ROM
  1718. X    nop
  1719. X    nop
  1720. X    nop
  1721. X    nop
  1722. XRAMBootEnd:
  1723. X
  1724. X_BootCode:
  1725. X    dc.l    RAMBootCode
  1726. X_BootCodeSize:
  1727. X    dc.l    RAMBootEnd-RAMBootCode+1
  1728. X
  1729. X;======================================================================
  1730. X;
  1731. X;    This routine forces a boot back to ROM, clearing out the 
  1732. X;    ExecBase and turning off the MMU and caches.  
  1733. X;
  1734. X;    void CleanBoot(void)
  1735. X;
  1736. X;======================================================================
  1737. X
  1738. X_CleanBoot:
  1739. X    move.l    4,a6
  1740. X
  1741. X    lea    1$,a5
  1742. X    CALLSYS    Supervisor
  1743. X    rts
  1744. X1$
  1745. X    move.l    #0,(sp)            ; Turn off MMU
  1746. X    move.l    sp,a0
  1747. X    PMOVE_    (a0),tc            ; -> $f010,$4000
  1748. X
  1749. X    move.l    #0,d1            ; Turn all caches off
  1750. X    MOVEC_    d1,cacr
  1751. X
  1752. X    move.l    4,a6            ; Clear out ExecBase
  1753. X    move.l    #0,$4
  1754. X
  1755. X    move.l    $00f80000,d0        ; Which kind of real ROM?
  1756. X    cmp.l    #$11144ef9,d0
  1757. X    beq    2$
  1758. X    move.l    $00fc0004,a0
  1759. X    bra 3$
  1760. X2$
  1761. X    move.l    $00f80004,a0        ; We have a 512K ROM
  1762. X3$
  1763. X    reset
  1764. X    reset
  1765. X    jmp (a0)
  1766. X    nop
  1767. X    nop
  1768. X    nop
  1769. X    nop
  1770. XCleanBootEnd:
  1771. X
  1772. X;======================================================================
  1773. X;
  1774. X;    Pointers to the smart reset routine, and the length of this
  1775. X;    routine.  Currently I'm using the CleanBoot routine, which will
  1776. X;    get the machine back to the ROM OS.  A better smart reset routine
  1777. X;    could boot back to the virtual ROM rather than the physcial ROM.
  1778. X;
  1779. X;======================================================================
  1780. X
  1781. X_ResetCode:
  1782. X    dc.l    _CleanBoot
  1783. X_ResetCodeSize:
  1784. X    dc.l    CleanBootEnd-_CleanBoot+1
  1785. X
  1786. X    end
  1787. END_OF_FILE
  1788. if test 5211 -ne `wc -c <'reboot.a'`; then
  1789.     echo shar: \"'reboot.a'\" unpacked with wrong size!
  1790. fi
  1791. # end of 'reboot.a'
  1792. fi
  1793. if test -f 'setcpu.i' -a "${1}" != "-c" ; then 
  1794.   echo shar: Will not clobber existing file \"'setcpu.i'\"
  1795. else
  1796. echo shar: Extracting \"'setcpu.i'\" \(4271 characters\)
  1797. sed "s/^X//" >'setcpu.i' <<'END_OF_FILE'
  1798. X;======================================================================
  1799. X;
  1800. X;    SetCPU V1.60
  1801. X;    by Dave Haynie, April 13, 1990
  1802. X;    Released to the Public Domain
  1803. X;
  1804. X;    Assembly Header File
  1805. X;
  1806. X;    All assembly files need this included
  1807. X;
  1808. X;======================================================================
  1809. X
  1810. X;======================================================================
  1811. X;
  1812. X;    Macros & constants used herein.  The Manx assembler is supposed
  1813. X;    to handle the 68881 and some of the 68020/30 instructions, but
  1814. X;    these macros will help out on older assemblers, and complete the
  1815. X;    set of instructions I need.
  1816. X;
  1817. X;======================================================================
  1818. X
  1819. XCALLSYS        macro   *
  1820. X        jsr     LVO\1(A6)
  1821. X        endm
  1822. X
  1823. XPMOVE_        macro    *
  1824. X        ifc '\1','tc'
  1825. X            ifc '\2','(sp)'
  1826. X            dc.w    $f017    ; PMOVE tc,(sp)
  1827. X            dc.w    $4200
  1828. X            mexit
  1829. X            endc
  1830. X            ifc '\2','(a0)'
  1831. X            dc.w    $f010    ; PMOVE tc,(a0)
  1832. X            dc.w    $4200
  1833. X            mexit
  1834. X            endc
  1835. X        endc
  1836. X        ifc '\1','crp'
  1837. X            ifc '\2','(a0)'
  1838. X            dc.w    $f010    ; PMOVE    crp,(a0)
  1839. X            dc.w    $4e00
  1840. X            mexit
  1841. X            endc
  1842. X        endc
  1843. X        ifc '\1','(a0)'
  1844. X            ifc '\2','crp'
  1845. X            dc.w    $f010    ; PMOVE    (a0),crp
  1846. X            dc.w    $4c00
  1847. X            mexit
  1848. X            endc
  1849. X            ifc '\2','tc'
  1850. X            dc.w    $f010    ; PMOVE (a0),tc
  1851. X            dc.w    $4000
  1852. X            mexit
  1853. X            endc
  1854. X        endc
  1855. X        ifc '\1','(a1)'
  1856. X            ifc '\2','crp'
  1857. X            dc.w    $f011    ; PMOVE (a1),crp
  1858. X            dc.w    $4c00
  1859. X            mexit
  1860. X            endc
  1861. X        endc
  1862. X        endm
  1863. XPFLUSHA_    macro    *
  1864. X        dc.w    $f000
  1865. X        dc.w    $2400
  1866. X        endm
  1867. X
  1868. XMOVEC_        macro    *
  1869. X        ifc '\1','cacr'
  1870. X            ifc '\2','d0'
  1871. X            dc.w    $4e7a    ; MOVEC    cacr,d0
  1872. X            dc.w    $0002
  1873. X            mexit
  1874. X            endc
  1875. X            ifc '\2','d1'
  1876. X            dc.w    $4e7a    ; MOVEC    cacr,d1
  1877. X            dc.w    $1002
  1878. X            mexit
  1879. X            endc
  1880. X        endc
  1881. X        ifc '\2','cacr'
  1882. X            ifc '\1','d0'
  1883. X            dc.w    $4e7b    ; MOVEC d0,cacr
  1884. X            dc.w    $0002
  1885. X            mexit
  1886. X            endc
  1887. X            ifc '\1','d1'
  1888. X            dc.w    $4e7b    ; MOVEC d1,cacr
  1889. X            dc.w    $1002
  1890. X            mexit
  1891. X            endc
  1892. X        endc
  1893. X        ifc '\1','vbr'
  1894. X            ifc '\2','d0'
  1895. X            dc.w    $4e7a    ; MOVEC    vbr,d0
  1896. X            dc.w    $0801
  1897. X            mexit
  1898. X            endc
  1899. X        endm
  1900. X
  1901. XCIB_ENABLE    EQU    0
  1902. XCIB_FREEZE    EQU    1
  1903. XCIB_ENTRY    EQU    2
  1904. XCIB_CLEAR    EQU    3
  1905. XCIB_BURST    EQU    4
  1906. X
  1907. XCDB_ENABLE    EQU    8
  1908. XCDB_FREEZE    EQU    9
  1909. XCDB_ENTRY    EQU    10
  1910. XCDB_CLEAR    EQU    11
  1911. XCDB_BURST    EQU    12
  1912. XCDB_WALLOC    EQU    13
  1913. X
  1914. XCIB_ENABLE40    EQU    15
  1915. XCDB_ENABLE40    EQU    31
  1916. X
  1917. XAFB_68030    EQU    2
  1918. XAFB_68040    EQU    3
  1919. XAFB_68882    EQU    5
  1920. X
  1921. XATNFLGS        EQU    $129
  1922. X
  1923. XLVOSupervisor    EQU    -30
  1924. XLVOSuperState    EQU    -150
  1925. XLVOFindTask    EQU    -294
  1926. XLVOAllocTrap    EQU    -342
  1927. XLVOFreeTrap    EQU    -348
  1928. XLVOCacheClearU    EQU    -636
  1929. XLVOCacheControl    EQU    -648
  1930. X
  1931. XANYCREG        EQU    $00dff010
  1932. X
  1933. X;======================================================================
  1934. X;
  1935. X;    Need just a little more stuff
  1936. X;
  1937. X;======================================================================
  1938. X
  1939. X    NOLIST
  1940. X    include "exec/types.i"
  1941. X    include "exec/execbase.i"
  1942. X    include "exec/tasks.i"
  1943. X    LIST
  1944. X
  1945. X;======================================================================
  1946. X;
  1947. X;    The assembly version of my tag structure
  1948. X;
  1949. X;======================================================================
  1950. X
  1951. X STRUCTURE    TAG,0
  1952. X   ULONG     TAG_TAGSIZE        ; Size of this tag
  1953. X   ULONG    TAG_PROGVER        ; The program version
  1954. X   APTR        TAG_MAINTABLE        ; The main ROM table
  1955. X   APTR        TAG_ROMHI        ; The main ROM image
  1956. X   UWORD     TAG_ROMTYPE        ; Type of MMU ROM
  1957. X   UWORD     TAG_PATCHES        ; The number of other patches applied
  1958. X   APTR     TAG_PATCHLIST        ; List of installed patches
  1959. X   APTR        TAG_DEVS        ; Translated device ROMs
  1960. X   ULONG    TAG_TC            ; Precomputed TC used for KICK.
  1961. X   ULONG    TAG_CRP_0        ; Precomputed CRP used for KICK.
  1962. X   ULONG    TAG_CRP_1
  1963. X   UWORD    TAG_CONFIG        ; Configuration status.
  1964. X   ULONG    TAG_BERRSIZE        ; Size of bus error handler.
  1965. X   APTR        TAG_OLDBERR        ; The old BERR routine.
  1966. X   APTR        TAG_BERRHANDLER        ; My BERR routine.
  1967. X   SHORT    TAG_WRAPUP        ; Upper address wrap bound.
  1968. X   SHORT    TAG_WRAPDOWN        ; Lower address wrap bound.
  1969. X   ULONG    TAG_TABLESIZE        ; Main table size.
  1970. X   APTR        TAG_RESETCODE        ; Actual reset routine
  1971. X   ULONG    TAG_ROMSIZE        ; Size of ROM image
  1972. X   ULONG    TAG_ROMLOC        ; Where does the fool thing go?
  1973. X   ULONG    TAG_ROMSTART        ; And where do we start it up? 
  1974. X   APTR        TAG_ROMLO        ; Secondary ROM image, if needed
  1975. X   APTR        TAG_SYSSTACK        ; Physical system stack image
  1976. X   ULONG    TAG_SYSSTKSIZE        ; System Stack allocated size
  1977. X   ULONG    TAG_RESETSIZE        ; Size of the reset code.
  1978. X   APTR        TAG_OLDRESET        ; Old Reset Code
  1979. X   LABEL    TAG_SIZE
  1980. X
  1981. X;TAG_TC        EQU    28
  1982. X;TAG_CRP_0    EQU    32
  1983. X;TAG_RESETCODE    EQU    62
  1984. X;TAG_ROMSTART    EQU    74
  1985. X
  1986. X    machine mc68020
  1987. X        mc68881
  1988. X
  1989. END_OF_FILE
  1990. if test 4271 -ne `wc -c <'setcpu.i'`; then
  1991.     echo shar: \"'setcpu.i'\" unpacked with wrong size!
  1992. fi
  1993. # end of 'setcpu.i'
  1994. fi
  1995. echo shar: End of archive 1 \(of 4\).
  1996. cp /dev/null ark1isdone
  1997. MISSING=""
  1998. for I in 1 2 3 4 ; do
  1999.     if test ! -f ark${I}isdone ; then
  2000.     MISSING="${MISSING} ${I}"
  2001.     fi
  2002. done
  2003. if test "${MISSING}" = "" ; then
  2004.     echo You have unpacked all 4 archives.
  2005.     rm -f ark[1-9]isdone
  2006. else
  2007.     echo You still need to unpack the following archives:
  2008.     echo "        " ${MISSING}
  2009. fi
  2010. ##  End of shell archive.
  2011. exit 0
  2012. -- 
  2013. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  2014. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  2015. Post requests for sources, and general discussion to comp.sys.amiga.
  2016.